home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 3 / Cream of the Crop 3.iso / comm / dep309.zip / DEPARC.EXE / SCRIPTS.EXE / TIMER.DSL < prev    next >
Text File  |  1992-09-21  |  3KB  |  84 lines

  1. (* TIMER for Deputy Version 1.0  1st August 1992
  2.    Translated from Timer V.8.1 14/1/92
  3.    Set time of execution of another script
  4.    With thanks to Rtrue for the original script *)
  5.  
  6. SCRIPT Timer;
  7. VAR Cver:String[4];             (* Version *)
  8.     Schain:String;              (* Script to chain to *)
  9.     Gtime:String[8];            (* Time to start *)
  10.     Ntime:String[8];            (* Time now *)
  11.     Rtime:String[8];            (* Time remaining *)
  12.  
  13. (* First, define a function to calculate elapsed time *)
  14.  
  15. FUNC Felapsed(Stime:String;Etime:String):String;
  16. VAR Shour,Smin,Ssec,Ehour,Emin,Esec:Number;
  17.     Selapsed,Tstr:String[8];
  18. BEGIN
  19.     StrToInt(Slice(Stime,0,2),Shour);
  20.     StrToInt(Slice(Stime,3,2),Smin);
  21.     StrToInt(Slice(Stime,6,2),Ssec);
  22.     StrToInt(Slice(Etime,0,2),Ehour);
  23.     StrToInt(Slice(Etime,3,2),Emin);
  24.     StrToInt(Slice(Etime,6,2),Esec);
  25.     IF Ssec>Esec THEN
  26.         INC(Smin);
  27.         INC(Esec,60);
  28.     END;
  29.     IF Smin>Emin THEN
  30.         INC(Shour);
  31.         INC(Emin,60);
  32.     END;
  33.     IF Shour>Ehour THEN
  34.         INC(Ehour,24);
  35.     END;
  36.     IntToStr(Ehour-Shour+100,Tstr);
  37.     Selapsed:=Slice(Tstr,1,2);
  38.     IntToStr(Emin-Smin+100,Tstr);
  39.     Selapsed:=Selapsed+":"+Slice(Tstr,1,2);
  40.     IntToStr(Esec-Ssec+100,Tstr);
  41.     Selapsed:=Selapsed+":"+Slice(Tstr,1,2);
  42.     RETURN Selapsed;
  43. END;
  44.  
  45.  
  46. (* Now here's the start of main script *)
  47.  
  48. BEGIN
  49.     Cver:="V1.0";                   (* Version *)
  50.     ClrScr();
  51.     Write("                  "+
  52.         "█▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀█\r\n");
  53.     Write("                  "+
  54.         "█   TIMER  "+Cver+" - Timed script execution   █\r\n");
  55.     Write("                  "+
  56.         "█▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄█\r\n\n\n");
  57.     Write("Please enter the name of the script to be executed\r\n\n");
  58.     Read(Schain); WrLn;
  59.     Write("Please enter the time it is to be executed as HH:MM:SS\r\n");
  60.     REPEAT
  61.         GoToXY(0,11);
  62.         Write("                                        ");
  63.         GoToXY(0,11);
  64.         Read(Gtime);
  65.     UNTIL (Length(Gtime)=8) AND (Slice(Gtime,2,1)=":") AND
  66.         (Slice(Gtime,5,1)=":");
  67.     Write("\r\n\n");
  68.     Write("          Time Now      Time to Execute    Time Remaining\n\r");
  69.     Write("          --------      ---------------    --------------\n\r\n");
  70.  
  71.     REPEAT
  72.         Ntime:=Time();
  73.         Rtime:=Felapsed(Ntime,Gtime);
  74.  
  75.         Cursor(FALSE);
  76.         GoToXY(10,16);
  77.         Write(Ntime+"          "+Gtime+"          "+Rtime+"\r\n\n");
  78.         Cursor(TRUE);
  79.     UNTIL Rtime="00:00:00";
  80.  
  81.     Write("\n\n\r");
  82.     Chain(Schain+".SCR");
  83. END Timer.
  84.